<%@page import="com.aliyuncs.http.HttpResponse"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/commons/global.jsp"%>
<%@ include file="/commons/tag.jsp"%>
<%@ include file="/commons/js/basejs.jsp"%>
<%@ include file="/commons/js/extjs.jsp"%>
<%@ include file="/commons/css/basecss.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<body id="mainBody" class="easyui-layout">
<div id="win" class="easyui-window" title="My Window" style="width:600px;height:400px"   
        data-options="iconCls:'icon-save',modal:true,closed:true">  
      

</div>
<div id="win2"></div>
<input class="easyui-textbox" style="width:100px;">
	<div class="easyui-layout" data-options="fit:true,border:false" style="overflow: hidden;width:100%">
        <div data-options="region:'center',border:false"  >
            
        </div>
    </div>
    <div data-options="region:'center'" style="overflow-x: hidden">
		<div id="tabs" class="easyui-tabs" data-options="fit:true,border:false">
			<div id="systemMenu" title="订单列表">
			<!-- <table id="table1"></table> -->
				<div id="datagrid_toolbar">
			 	 请选择厂商 :
				<input id="fac" class="easyui-combobox" name="fac" 
		  		  data-options="valueField:'label',textField:'value',url:'${base}/SystemProduct/findAllFactory'"/>  
				关键字:
				<input id="keyword" class="text" name="keyword" placeholder="包括订单编号/厂商名称/经销商名称"/>  
			        <a onclick="doSearch()" href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-search'">查看</a>
			        <div class="td_right">
						<!-- <a onclick=";" href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-add'">添加</a> -->
						<a onclick="testOnclick()" href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-edit'">编辑</a>
				       	<a onclick="deletes()" href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-del'">删除</a>
			       	</div>
				</div>
			</div>
		</div>
	</div>
</div>
	
	<script type="text/javascript">
	$(function(){
		$('#table1').datagrid({
			url: '${base}/SystemOrder/findBySenior',
			fit: true,
			border: false,
			pagination: true,// 分页
			pagePosition: 'bottom',
			idField: 'id',
			pageSize: 30,
			pageList: [10,20,30,50],
			checkOnSelect: true,
			selectOnCheck: true,
			singleSelect: false,
			nowrap: true, 
			rownumbers: true, //显示行号
			showfooter: true, //显示行尾
			pageNumber: 1,
			fitColumns:true,
			sortName: 'updateTime',	//按字段排序
			sortOrder: 'desc',		//倒序
			toolbar:'#datagrid_toolbar',
			columns : [[
			 {field : 'id', title :'id', width : 50, hidden: true},
			 {field : 'orderNo', title:'订单名称', width : '20%', align : 'center'},
			 {field : 'facName', title:'厂商名称', width : '20%', align : 'center'},
			 {field : 'ageName', title:'经销商名称', width : '15%', align : 'center'},
			 {field : 'amountTotal', title:'订单金额', width : '15%', align : 'center'},
			 {field : 'orderStatus', title:'订单状态', width : '15%', align : 'center',sortable:true,
				 //订单状态：0，待审核；1，待财务审核；2，待发货；3，部分发货：4，待收货；5，确认收货；6，订单完成：9，暂存；10，作废
				 formatter:function(value,row,index){
			 		 if (0 == value) return '待审核';
					 else if (1 == value) return '待财务审核';
					 else if (2 == value) return '待发货';
					 else if (3 == value) return '部分发货';
					 else if (4 == value) return '待收货';
					 else if (5 == value) return '确认收货';
					 else if (6 == value) return '订单完成';
					 else if (9 == value) return '暂存';
					 else return '';
			 	}},
			 {field : 'payStatus', title:'支付状态', width : '15%', align : 'center',sortable:true,
			 		//付款状态：0=未付款；1=部分付款；2=已经付款；3=待确认
				 	formatter:function(value,row,index){
				 		 if (0 == value) return '未付款';
						 else if (1 == value) return '部分付款';
						 else if (2 == value) return '已经付款';
						 else if (3 == value) return '待确认';
						 else return '';
				 	}}/* ,
			 {field :'action', title:'操作', width:80, align:'center',
					formatter:function(value,row,index){
						var e = '<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:\'icon-edit\',plain:true" onclick="hiddangerinfo_table_editrow(this)">编辑</a> ';
						var d = '<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:\'icon-del\',plain:true" onclick="hiddangerinfo_table_deleterow(this)">删除</a>';
						return e+d;
					}
				} */]],
	   });
	});
	
	function testOnclick(){
		$.ajax({  
            type : "POST",  
            url : "${base}/SystemOrder/payTest",
            data : {},
            success : function(result) {
            	//var s="<div class='style'>"+result+"</div>"	;
            	//document.getElementById('win').innerHTML=result;  
            	// alert(result);
            	document.getElementById('win2').innerHTML=666; 
    	    	//$('#win').window('open'); 
            	console.info(result);
            }  
        });      
	}
		function deletes(){
			/*  swal({
			    title: "确定删除吗？",
			    text: "你将无法恢复该虚拟文件！",
			    type: "warning",
			    showCancelButton: true,
			    confirmButtonColor: "#DD6B55",
			    confirmButtonText: "确定删除！",
			    closeOnConfirm: false
			},
			function(){
			    swal("删除！",
			    "你的虚拟文件已经被删除。",
			    "success");
			});  */
			 var row = $('#table1').datagrid('getSelections');
			var ids = "";
				for(var i in row){
					ids += ","+row[i].id;
				}
				console.info(ids);
			   $.ajax({  
                type : "POST",  
                url : "${base}/SystemOrder/deleteOrder",
                data : {
                	ids: ids
                },
                success : function(result) {
                	if(result == 0){
                    	swal("", "删除失败,包含默认商品","error");
                	} else {
                		/* swal("", "删除成功","success"); */
                	}
                	$('#table1').datagrid('load',{
						condition: $('#keyword').val(),
						facId: $('#fac').combobox('getValue')
					});
                }  
            });      
		}
		function doSearch(){
			$('#table1').datagrid('load',{
				keyword: $('#keyword').val(),
				facId: $('#fac').combobox('getValue')
			});
		}
	</script>
	
</body>
</html>